/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.felinelayer.server.application;

import java.util.ArrayList;

/**
 *
 * @author home
 */
public class GridColumnServer {
    
    public static final int COLUMN_TYPE_STRING = 0;
    public static final int COLUMN_TYPE_NUMERIC = 1;
    public static final int COLUMN_TYPE_DATE = 2;
    
    public static final int COLUMN_ALIGMENT_DEFAULT = 0;
    public static final int COLUMN_ALIGMENT_LEFT = 1;
    public static final int COLUMN_ALIGMENT_CENTER = 2;
    public static final int COLUMN_ALIGMENT_RIGHT = 3;
    
    public String title;
    public int type;
    public int aligment;
    public int index;
    
    public static GridColumnServer createColumn(String title, int type) {
        GridColumnServer column = new GridColumnServer();
        column.title = title;
        column.type = type;
        return column;
    }
    
    public static GridColumnServer addInt(String title) {
        return add(title, GridColumnServer.COLUMN_TYPE_NUMERIC);
    }
    
    public static GridColumnServer addStr(String title) {
        return add(title, GridColumnServer.COLUMN_TYPE_STRING);
    }
    
    public static GridColumnServer addDat(String title) {
        return add(title, GridColumnServer.COLUMN_TYPE_DATE);
    }
    
    public static GridColumnServer add(String title, int type) {
        GridColumnServer column = createColumn(title, type);
        if (columns == null) {
            columns = new ArrayList<>();
        }
        column.index = columns.size();
        columns.add(column);
        return column;
    }
    private static ArrayList<GridColumnServer> columns;
    
    public static GridColumnServer[] make() {
        if (columns == null) {
            return null;
        }
        GridColumnServer[] cs = columns.toArray(new GridColumnServer[columns.size()]);
        columns.clear();
        return cs;
    }
    
    
}
